Ext.define('Projeto.controller.Menu', {
    extend: 'Ext.app.Controller',
	
    stores: ['Menu'],
	
    refs: [{
        ref: 'tabContainer',
        selector: 'tabpanel[id=tabMainContainer]'
    }],
	
    init: function() {
        this.control({
            'menulist': {
                select: this.onMenuSelect
            }
        });
    },

    onMenuSelect: function(rowModel, record, index, opts) {
        var newTab = record.get('type');
        if (!this.getTabContainer().child(newTab)) {
            this.getTabContainer().add({
                xtype:newTab
            });
            this.getTabContainer().setActiveTab(newTab);
        } else {
            this.getTabContainer().setActiveTab(newTab);
        }
    }
});